// pages/out/detials/details.js
var app=getApp()
var url=app.globalData.url
var url1 = app.globalData.url1
var rid=''
Page({

  /**
   * 页面的初始数据
   */
  data: {
    details:[],
    names:"返修详情",
    flag:true
  },
back(){
  wx.navigateBack()
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    rid = options.orderId
  var that=this
   that.getDetails(rid)
  },
  getDetails: function (rid) {
    var that = this
    wx.request({
      url:url1+'/AfterSale/selectAfterSaleByAid',
      data: {
        aId: rid
      },
      header: {
        'content-type': 'application/json'
      },
      method: "GET",
      success: function (res) {
        console.log("详情：")
         console.log(res.data)
       
        if (res.data.astatus==0){
           that.setData({
             messge:'审核中'
           })
        } else if (res.data.astatus == 1){
          that.setData({
            messge: '通过',
            yinzhang:"../image/pass.png"
          })
        }
        else{
          that.setData({
            messge: '失败',
            yinzhang: "../image/fail.png"
          })
        }
        that.setData({
          details:res.data
        })

      },
      fail(res){
        console.log(res.data+"---fail  reparte")
      }
    })
   
  },
   cansleFanxiu: function (e) {
    var that = this
    wx.showModal({
      content: '确认取消',
      success: function (res) {
        if (res.confirm) {
          wx.request({
            url: url + '/orders/deleteFxOrder?ordersId=' + e.target.id,
            method: "GET",
            header: {
              'content-type': 'application/json'
            },
            success(res) {


              if (res.data.code == '100') {
                wx.showToast({
                  title: '取消成功',
                  icon: 'success',
                  duration: 3000
                })
                that.getDetails()
              } else {
                wx.showToast({
                  title: '取消失败',
                  icon: 'success',
                  duration: 3000
                })
                
              }


            }
          })
        }
      }
    })
  },
  toKefu: function (res) {
    wx.makePhoneCall({
      phoneNumber: res.currentTarget.dataset.phone,
      success: function () {
        console.log("成功拨打电话")
      }
    })

  },
  toshifu: function (e) {
    wx.showModal({
      content: '为了保护您的隐私此号码为虚拟号码！',
      success(res) {
        if (res.confirm) {
          var that = this
          var phoneX = e.currentTarget.id
          var subsId = e.currentTarget.dataset.subsid

          wx.request({
            url: url + '/orders/overdueTF',
            data: {
              phoneX: phoneX,
              subsId: subsId
            },
            success: function (data) {
              console.log(data.data)
              if (data.data.code === '100') {//绑定有效
                wx.makePhoneCall({
                  phoneNumber: phoneX,
                  success: function () {
                    console.log("成功拨打电话")
                  }
                })
              } else {

                wx.makePhoneCall({
                  phoneNumber: '4000219339',
                  success: function () {
                    console.log("成功拨打电话")
                  }
                })

              }
            }
          })
        }
      }
    })
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },


  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})